import request from "@/utils/request";

/**
 * 获取商品列表数据
 * @param params
 * @returns {Promise<unknown>}
 */
export function getCancelReturnOrder(params = {}){
  return request({
    url: '/hardware/getCancelReturnOrder',
    method: 'get',
    params,
    handleError: true,
  })
}


/**
 * 获取货件
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getShipmentListByHW(params = {}){
  return request({
    url: '/hardware/getShipmentListByHW',
    params,
    handleError: true,
  })
}

/**
 * 获取拣货订单
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getPickOrder(params){
  return request({
    url: '/hardware/getPickOrder',
    params,
    timeout: 60000 * 5,
    handleError: true
  })
}

/**
 * 贴单操作
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function stickerOrder(data){
  return request({
    url: '/hardware/stickerOrder',
    data,
    method: 'patch',
    handleError: true,
  })
}

/**
 * 演示模式专用获取sku数据
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getTestingSkuOrder(params){
  return request({
    url: '/hardware/getTestingSkuOrder',
    params,
    handleError: true,
  })
}

/**
 *
 * @returns {Promise | Promise<unknown>}
 */
export function getMinoShippingHWTestPDF(params = {}){
  return request({
    url:`/hardware/getMinoShippingHWTestPDF`,
    responseType: "arraybuffer", // 需要加上
    isNotJson:true,
    timeout: 60000, // 1分钟
    params,
  })
}


/**
 * 获取调货工单列表数据
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getTransferListByHW(params){
  return request({
    url: `/hardware/getTransferListByHW`,
    params,
    handleError: true
  })
}

/**
 * 获取送仓工单
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getMiddleListByHM(params){
  return request({
    url: `/hardware/getMiddleListByHM`,
    params,
    handleError: true
  })
}


/**
 * 获取贴标工单列表
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function getLabelListByHM(params){
  return request({
    url: `/hardware/getLabelListByHM`,
    params,
    handleError: true,
  })
}


/**
 * 批量保存送仓数据
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export function batchSaveMiddleGoodsNum(data){
  return request({
    url: `/hardware/batchSaveMiddleGoodsNum`,
    data,
    method: 'put',
    handleError: true,
  })
}
export function batchSaveTransferGoodsNum(data){
  return request({
    url: `/hardware/batchSaveTransferGoodsNum`,
    data,
    method: 'put',
    handleError: true,
  })
}
export function batchSaveLabelGoodsNum(data){
  return request({
    url: `/hardware/batchSaveLabelGoodsNum`,
    data,
    method: 'put',
    handleError: true,
  })
}


/**
 * 获取箱标对应的信息
 * @param keyword
 * @returns {Promise | Promise<unknown>}
 */
export function getBoxLabelInfo(keyword){
  return request({
    url: '/hardware/getBoxLabelInfo',
    params : {
      keyword: keyword,
    },
    method: 'get',
  })
}

/**
 * 标记箱标已扫描
 * @param boxId
 * @returns {Promise | Promise<unknown>}
 */
export function saveBoxLabelScan(boxId){
  return request({
    url: `/hardware/saveBoxLabelScan/${boxId}`,
    method: 'patch',
  })
}


/**
 * 分拣模式扫描箱唛
 * @param params
 * @returns {Promise | Promise<unknown>}
 */
export function sortingScanBox(params){
  return request({
    url: '/hardware/sortingScanBox',
    method: 'get',
    params,
    handleError: true,
  })
}
